// import { DECREMENT, INCREMENT } from "../const/counter.const";
import { handleActions as createReducer } from 'redux-actions';
import { increment, decrement } from '../actions/counter.actions';

const initialState = {
  count: 0
}

const handleIncrement = (state, action) => ({
  ...state,
  count: state.count + action.payload
})

const handleDecrement = (state, action) => ({
  ...state,
  count: state.count - action.payload
})

export default createReducer({
  [increment]: handleIncrement,
  [decrement]: handleDecrement,
}, initialState);

// export default function reducer(state = initialState, action) {
//   switch (action.type) {
//     case INCREMENT:
//       return {
//         ...state,
//         count: state.count + action.payload
//       }
//     case DECREMENT:
//       return {
//         ...state,
//         count: state.count - action.payload
//       }
//     default:
//       return state
//   }
// }